package cn.edu.sasu;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.widget.ImageView;

/**
 * 项目启动的时候运行的欢迎界面，用动画来完成的
 * 
 * @author fish
 */
public class WelcomeActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// 全屏幕
		getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
				WindowManager.LayoutParams.FLAG_FULLSCREEN);

		setContentView(R.layout.welcome);
		// setContentView(R.layout.welcome);

		ImageView animBg = (ImageView) findViewById(R.id.img_logo);
		// 创建一个透明度动画对象，启动的时候，图片逐渐消失
		Animation anim = new AlphaAnimation(0.0f, 1.0f);
		anim.setDuration(3000);
		anim.setAnimationListener(new AnimationListener() {

			@Override
			public void onAnimationStart(Animation arg0) {

			}

			@Override
			public void onAnimationRepeat(Animation arg0) {

			}

			@Override
			public void onAnimationEnd(Animation arg0) {
				Intent intent = new Intent(WelcomeActivity.this,
						MainActivity.class);
				startActivity(intent);
				overridePendingTransition(R.anim.entercontent,
						R.anim.exitcontent);
				finish();
			}
		});
		animBg.setAnimation(anim);
		// 开始动画
		anim.start();

	}

}
